import java.util.Scanner;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int year = sc.nextInt();
            int month = sc.nextInt();
            int day = sc.nextInt();
        
            int[] a = {31,28,31,30,31,30,31,31,30,31,30,31};
            int[] b = {31,29,31,30,31,30,31,31,30,31,30,31};
            if(isLeapYear(year)){
                System.out.println(countDays(b,month,day));
            }else{
                System.out.println(countDays(a,month,day));
            }
        }
    }
    
    public static boolean isLeapYear(int year){
        if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
            return true;
        }
        return false;
    }
    
    public static int countDays(int[] arr, int month, int day){
        int sum = 0;
        for(int i = 0; i < month-1; i++){
            sum += arr[i];
        }
        sum += day;
        return sum;
    }
    
    
}